package com.qf;

/**
 * @author 孙亚梅
 * @version V1.0
 * @Project javase2203
 * @Package com.qf.controller
 * @Description:
 * @Date 2022/6/9 16:47
 */

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 演示跨域访问问题和解决方案
 */
@Controller
@RequestMapping("/origin")
//解决跨域访问问题
@CrossOrigin("http://localhost:8081")//允许来自8081服务器发来的请求
public class CrossController {
    /**
     * 跨域访问方法
     */
    @RequestMapping("/test1")
    @ResponseBody
    public  String test1(){
        System.out.println("======访问到了跨域的controller方法=====");
        return  "ok";
    }
}
